import Vue from "vue";
import VueRouter from "vue-router";


const index = resolve => require(["@/components/index"], resolve);

const blogList = resolve => require(["@/components/blog-list"], resolve);
const blogDetail = resolve => require(["@/components/blog-detail"], resolve);
const blogTag = resolve => require(["@/components/blog-tag-list"], resolve);
const blogArchive = resolve => require(["@/components/blog-archive"], resolve);
const contact = resolve => require(["@/components/contact"], resolve);
const about = resolve => require(["@/components/about"], resolve);


Vue.use(VueRouter);

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default new VueRouter({
    routes: [
        {
          path: "/",
          name: 'main',
          component: index,
          redirect: '/index/blog-list',
        },
        {
            path: '/index',
            name: 'index',
            component: index,
            children: [
                {
                  path: 'blog-list',
                  name: 'blog-list',
                  component: blogList,
                },
            ]
        },
        {
            path: '/index',
            name: 'index',
            component: index,
            children: [
                {
                    path: "blog-detail/:id",
                    name: 'blogDetail',
                    component: blogDetail,
                    props: true,
                },
            ]
        },
        {
            path: '/index',
            name: 'index',
            component: index,
            children: [
                {
                    path: "blog-tag/:id",
                    name: 'blogTag',
                    component: blogTag,
                    props: true,
                },
            ]
        },
        {
            path: '/index',
            name: 'index',
            component: index,
            children: [
                {
                    path: 'blog-archive',
                    name: 'blogArchive',
                    component: blogArchive,
                },
            ]
        },
        {
            path: '/index',
            name: 'index',
            component: index,
            children: [
                {
                    path: 'contact',
                    name: 'contact',
                    component: contact,
                },
            ]
        },
        {
            path: '/index',
            name: 'index',
            component: index,
            children: [
                {
                    path: 'about',
                    name: 'about',
                    component: about,
                },
            ]
        },
    ]
})
